package com.ego.controller;

import com.ego.commons.exception.DaoException;
import com.ego.commons.pojo.EasyUIDatagrid;

import com.ego.commons.pojo.EgoResult;
import com.ego.pojo.TbItem;
import com.ego.pojo.TbItemParam;
import com.ego.service.TbItemParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


//@RestController=@Controller+每个方法上面自动添加@RequestBody
@RestController
public class TbItemParamController {

    @Autowired
    private TbItemParamService tbItemParamService;

    @RequestMapping("/item/param/list")
    public EasyUIDatagrid showItemparam(int page,int rows){
        return tbItemParamService.showItemParam(page,rows);
    }

    @RequestMapping("/item/param/query/itemcatid/{id}")
    public EgoResult showItemParamByCatId(@PathVariable Long id){
        return tbItemParamService.showParam(id);
    }

    @RequestMapping("/item/param/save/{catId}")
    public EgoResult insert(TbItemParam tbItemParam,@PathVariable Long catId) throws DaoException {
        tbItemParam.setItemCatId(catId);
        return this.tbItemParamService.insert(tbItemParam);
    }

    /**
     * 删除规格参数
     * @param ids
     * @return
     */
    @RequestMapping("/item/param/delete")
    public EgoResult delete(Long[] ids) {
        return this.tbItemParamService.delete(ids);
    }
}
